package com.example.neteasecloudmusic_kotlin.logic.network

import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

// 单例类，避免重复创建
object ServiceCreator {

    private const val BASE_URL = "https://dev.usemock.com/621a2c043cba06aedfdaf195/api/"

    private val retrofit = Retrofit.Builder()
        .baseUrl(BASE_URL)
        .addConverterFactory(GsonConverterFactory.create())
        .build()

    fun <T> create(serviceClass: Class<T>) : T = retrofit.create(serviceClass)

    // TODO： 实例化泛型类 必须？
    inline fun <reified T> create(): T = create(T::class.java)

}